package cn.birdbaby.plugins;

import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiClass;
import com.intellij.psi.PsiElement;
import com.intellij.refactoring.RefactoringFactory;
import com.intellij.refactoring.RenameRefactoring;

/**
 * @author llorando 3/8/24 1:28 pm
 */
public class TestListener extends AnAction {

    @Override
    public void actionPerformed(AnActionEvent e) {
        Project project = e.getData(CommonDataKeys.PROJECT);
        PsiElement psiElement = e.getData(CommonDataKeys.PSI_ELEMENT);

        if (project != null && psiElement instanceof PsiClass) {
            PsiClass psiClass = (PsiClass) psiElement;

            RefactoringFactory factory = RefactoringFactory.getInstance(project);
            RenameRefactoring refactoring = factory.createRename(psiClass, "");

        }
    }
}
